<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/libs/uploadify/css/uploadify.css"></link>

<link rel="stylesheet"
    href="${pageContext.request.contextPath}/libs/jquery-ui-1.10.3.custom/css/ui-lightness/jquery-ui-1.10.3.custom.css"></link>
<link rel="stylesheet"
    href="${pageContext.request.contextPath}/libs/jqgrid/css/ui.jqgrid.css"></link>

<script type="text/javascript"
    src="${pageContext.request.contextPath}/libs/jquery-1.9.0.min.js"></script>
<script type="text/javascript"
    src="${pageContext.request.contextPath}/libs/jqgrid/js/json2.js"></script>
<script type="text/javascript"
    src="${pageContext.request.contextPath}/libs/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>

    <script src="${pageContext.request.contextPath}/libs/uploadify/js/jquery.uploadify.min.js"  type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/libs/uploadify/js/jquery.fileDownload.js"  type="text/javascript"></script>

    <script type="text/javascript" src="${pageContext.request.contextPath}/libs/jqgrid/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript"
    src="${pageContext.request.contextPath}/libs/jqgrid/js/common.js"></script>

<script type="text/javascript">

$(function(){
$('#file_upload').uploadify({
    'buttonText'    :   '选择文件',  //上传文件按钮名称
    'fileObjName' : 'file_upload',
    'multi'         :   false,  //每次是否只能上传一个文件
    'swf'      : '${pageContext.request.contextPath}/libs/uploadify/css/uploadify.swf',
    'uploader' :  '${pageContext.request.contextPath}/file/upfile.action;jsessionid=<%=session.getId()%>',//文件上窜URL，固定URL
    'auto'          :   true,  //文件是否自动上传
    'uploadLimit': 9,//上传文件最大个数
    'onUploadSuccess' : function(file, data, response) {//文件上传成功后回调
       
    
        $.each(JSON.parse(data),function(k,v){
            
            alert(k+"----"+v);
        });
        
    }
});
});

$(document).on("click", "a.fileDownloadPromise", function () {
    $.fileDownload($(this).prop('href'))
        .done(function () { alert('File download a success!'); })
        .fail(function () { alert('File download failed!'); });
 
    return false; //this is critical to stop the click event which will trigger a normal file download
});
</script>
</head>
<body>
    <input id="file_upload" name="file_upload" type="file"  multiple="true"/>
    <!-- 文件下载beanId,必要参数，指定获取文件路径的服务 -->
    <a href="${pageContext.request.contextPath}/servlet/download?beanId=downLoadFileServiceImpl" class="fileDownloadPromise">Report4.pdf</a>
</body>
</html>